﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MussicWeb
{
    public partial class frmMain : Form
    {
        bool blick = false;
        bool bchecksize = false;

        public frmMain()
        {
            InitializeComponent();
        }

        #region xu ly cac nut controlsize
        private void btnexit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnmaximize_Click(object sender, EventArgs e)
        {
            if (bchecksize == false)
            {
                WindowState = FormWindowState.Maximized;
                bchecksize = true;
            }
            else
            {
                WindowState = FormWindowState.Normal;
                bchecksize = false;
            }
        }

        private void btnminimize_Click(object sender, EventArgs e)
        {
            WindowState = FormWindowState.Minimized;
        }

        private void ptxchangesize_Click(object sender, EventArgs e)
        {
            if (blick == false)
            {
                this.Size = new Size(600, 35);
                ptxchangesize.Image = global::MussicWeb.Properties.Resources.downloading_updates;
                this.TransparencyKey = Color.White;
                pnlMussic.BackColor = Color.White;
                this.Location = new Point(this.Width,0);
                blick = true;
            }
            else
            {
                this.Size = new Size(840, 370);
                ptxchangesize.Image = global::MussicWeb.Properties.Resources.upload;
                this.TransparencyKey = Color.Snow;
                pnlMussic.BackColor = Color.White;
                this.StartPosition = FormStartPosition.CenterScreen;
                blick = false;
            }
        }
        #endregion

        #region Di chuyen form
        // khai bao bien
        private bool dragging;
        private Point pointClick;

        /// <summary>
        /// xu ly khi nhap chuot vao form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pnlMussic_MouseDown(object sender, MouseEventArgs e)
        {
            pnlMussic.Cursor = Cursors.Hand;
            if (e.Button == MouseButtons.Left)
            {
                dragging = true;
                pointClick = new Point(e.X, e.Y);
            }
            else
            {
                dragging = false;
            }
        }

        private void pnlMussic_MouseUp(object sender, MouseEventArgs e)
        {
            dragging = false;
            pnlMussic.Cursor = Cursors.Default;
        }

        private void pnlMussic_MouseMove(object sender, MouseEventArgs e)
        {
            if (dragging == true)
            {
                Point pointMoveTo;
                pointMoveTo = this.PointToScreen(new Point(e.X, e.Y));
                pointMoveTo.Offset(-pointClick.X, -pointClick.Y);
                this.Location = pointMoveTo;
            }
        }
        #endregion

        private void frmMain_Load(object sender, EventArgs e)
        {
            ToolTip toolTip = new ToolTip();
            toolTip.SetToolTip(ptxrepeat,"Repeat");
            toolTip.SetToolTip(ptxrecord, "Record");
            toolTip.SetToolTip(ptxresum, "Previous");
            toolTip.SetToolTip(ptxrewind, "Rewind");
            toolTip.SetToolTip(ptxpause, "Pause");
            toolTip.SetToolTip(ptxforward, "Forward");
            toolTip.SetToolTip(ptxnext, "Next");
            toolTip.SetToolTip(ptxstop, "Stop");
            toolTip.SetToolTip(btnexit, "Exit");
            toolTip.SetToolTip(btnminimize, "Minimize");
            toolTip.SetToolTip(ptxfolder, "File");

        }

        private void progressBar1_Click(object sender, EventArgs e)
        {
            int percent = (int)(((double)progressBar1.Value / (double)progressBar1.Maximum) * 100);
            progressBar1.CreateGraphics().DrawString(percent.ToString() + "ten bai het o day %", new Font("Arial", (float)8.25, FontStyle.Regular),
                Brushes.Black, new PointF(progressBar1.Width / 2 - 10, progressBar1.Height / 2 - 7));
        }

        private void ptxfolder_Click(object sender, EventArgs e)
        {
            
        }

        private void ptxfolder_MouseHover(object sender, EventArgs e)
        {
            Panel pnlFile = new Panel();
            pnlFile.Location = new Point(2,5);
            pnlFile.Show();
        }
    }
}
